import axios from 'axios';
import NProgress from 'nprogress';
import {Message} from 'element-ui'
import 'nprogress/nprogress.css'

const mockAjax=axios.create({
    baseURL:'/mock',
    timeout:5000
})

mockAjax.interceptors.request.use( config=> {
  NProgress.start()
  return config;
  });
mockAjax.interceptors.response.use( 
  response=> {
  NProgress.done()
  return response.data;
},  
error=>{
  NProgress.done()
  Message.error(error.message)
  return Promise.reject(error.message);
});

export default mockAjax